package LeetCode_203;

import LeetCode_206.ListNode;

import java.util.List;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2022/10/22 22:27
 */
public class Solution {
    public static void main(String[] args) {
        ListNode l6 = new ListNode(6,null);
        ListNode l5 = new ListNode(5,l6);
        ListNode l4 = new ListNode(7,null);
        ListNode l3 = new ListNode(7,l4);
        ListNode l2 = new ListNode(7,l3);
        ListNode l1 = new ListNode(7,l2);
        removeElements(l1,7);
    }
    public static ListNode removeElements(ListNode head, int val) {
        if(head==null){
            return head;
        }
        ListNode header = new ListNode(-1,head);
        ListNode cur = header;
        //第一个

        while (cur.next != null){
            if (cur.next.val == val){
                cur.next = cur.next.next;
            }else {
                cur = cur.next;
            }
        }
        return head;
    }
}


